package com.copm.demonstrationsystem.service.introductionfeatures.commons;

import com.copm.demonstrationsystem.config.SystemConfig;
import com.copm.demonstrationsystem.pojo.commons.Image;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author: Yuan Baiyu
 * @Date: Created in 12:06 2018/6/13
 */
@Service
public class TransformImagePath {

    @Autowired
    private SystemConfig config;

    public Image transformImagePath(Image image) {
        image.setFileName("http://" + config.getServerIp() + ":" + config.getServerPort() + "/" + config.getApplicationName() + "/image/" + image.getFileName());
        image.setMiddle("http://" + config.getServerIp() + ":" + config.getServerPort() + "/" + config.getApplicationName() + "/image/" + image.getMiddle());
        image.setMin("http://" + config.getServerIp() + ":" + config.getServerPort() + "/" + config.getApplicationName() + "/image/" + image.getMin());
        return image;
    }
}
